package com.clhbolg.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.easyes.core.conditions.LambdaEsQueryWrapper;
import com.clhbolg.mapper.es.ArticlesSearchMapper;
import com.clhbolg.model.es.ArticleSearchDTO;
import com.clhbolg.service.IArticleService;
import com.ruoyi.common.core.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 调试接口
 *
 * @Author cailinhu
 * @Description TODO
 * @Date 2023/2/16 16:26
 * @Version 1.0
 */
@RestController
public class TestController extends BaseController {
    @Autowired
    IArticleService articleService;

    /**
     * 测试安全框架白名单
     *
     * @return ok
     */
    @GetMapping("/jmreport/list")
    public String test(){
        return "ok";
    }

    @Autowired
    private ArticlesSearchMapper articlesSearchMapper;
    /**
     * 测试导入文章到es
     * @return
     */
    @GetMapping("/toes")
    @SaIgnore
    public List testToEs(){
        articleService.saveArticleToEs();
        LambdaEsQueryWrapper<ArticleSearchDTO> articleSearchDTOLambdaEsQueryWrapper = new LambdaEsQueryWrapper<>();
        articleSearchDTOLambdaEsQueryWrapper.eq(ArticleSearchDTO::getIsDelete,0);
        List<ArticleSearchDTO> list = articlesSearchMapper.selectList(articleSearchDTOLambdaEsQueryWrapper);
        return list;
    }
}
